<?php

use Illuminate\Support\Facades\Route;

use App\Http\Controllers\Admin\Framework\Common\CaptchaController;
use App\Http\Controllers\Admin\Framework\Common\CenterController;
use App\Http\Controllers\Admin\Framework\Common\CommonController;
use App\Http\Controllers\Admin\Framework\Common\GalleryController;
use App\Http\Controllers\Admin\Framework\Common\ManageController;
use App\Http\Controllers\Admin\Framework\Common\PassportController;
use App\Http\Controllers\Admin\Framework\Manage\GroupController;
use App\Http\Controllers\Admin\Framework\Manage\LogController;
use App\Http\Controllers\Admin\Framework\Manage\MenusController;
use App\Http\Controllers\Admin\Framework\Manage\RoleController;
use App\Http\Controllers\Admin\Framework\Manage\UsersController;
use App\Http\Controllers\Admin\Framework\Setup\PageController;
use App\Http\Controllers\Admin\IndexController;

require base_path('routes/admin/routes.php');
// 获取验证码
Route::any('captcha/get', [CaptchaController::class, 'get']);
Route::any('captcha/check', [CaptchaController::class, 'check']);

// 登录
Route::any('passport/login', [PassportController::class, 'login']);
Route::post('passport/submit', [PassportController::class, 'submit']);
// 注销
Route::any('passport/logout', [PassportController::class, 'logout']);

Route::group(['middleware' => ['admin.sign']], function () {
    // 首页
    Route::any("/", [IndexController::class, 'index']);
    Route::any("/getStatistics", [IndexController::class, 'getStatistics']);
    Route::any("/getTopList", [IndexController::class, 'getTopList']);
    Route::any("/getTrend", [IndexController::class, 'getTrend']);

    // 基础架构
    Route::group(['prefix' => 'framework'], function () {

        // 公共
        Route::group(['prefix' => 'common'], function () {
            // 左边菜单栏
            Route::any("manage/leftMenuItems", [ManageController::class, 'leftMenuItems']);
            // 菜单操作按钮
            Route::any("manage/operationPermissions", [ManageController::class, 'operationPermissions']);
            // 菜单树形结构
            Route::any("manage/getMenuTrees", [ManageController::class, 'getMenuTrees']);
            // 组织树形结构
            Route::any("manage/getGroupTrees", [ManageController::class, 'getGroupTrees']);
            // 角色数据
            Route::any("manage/getRoleItems", [ManageController::class, 'getRoleItems']);
            // 图标数据
            Route::any("manage/getIcons", [ManageController::class, 'getIcons']);
            // 获取第三方云上传token
            Route::any("uploadToken", [CommonController::class, 'uploadToken']);
            Route::any("uploadEditor", [CommonController::class, 'uploadEditor']);// 富文本上传
            Route::any("pictureUploads", [CommonController::class, 'pictureUploads']);// 图片上传
            Route::any("fileUploads", [CommonController::class, 'fileUploads']);// 文件上传
            Route::any("getFileKey", [CommonController::class, 'getFileKey']);// 七牛云上传获取key
            Route::any("cacheClear", [CommonController::class, 'cacheClear']);// 七牛云上传获取key
            // 素材库
            Route::group(['prefix' => 'gallery'], function () {
                Route::any("iframe", [GalleryController::class, 'iframe']);
                Route::any("group", [GalleryController::class, 'group']);
                Route::any("insert", [GalleryController::class, 'insert']);
                Route::any("upload", [GalleryController::class, 'upload']);
                Route::any("remove", [GalleryController::class, 'remove']);
                Route::any("original", [GalleryController::class, 'original']);
                Route::any("groupCreate", [GalleryController::class, 'groupCreate']);
                Route::any("groupUpdate", [GalleryController::class, 'groupUpdate']);
                Route::any("groupRemove", [GalleryController::class, 'groupRemove']);
            });
            // 个人中心
            Route::group(['prefix' => 'center'], function () {
                Route::any("info", [CenterController::class, 'info']);
                Route::any("update", [CenterController::class, 'update']);
            });
        });

        // 设置
        Route::group(['prefix' => 'setup'], function () {
            Route::any("page/{__table}", [PageController::class, 'index']);
            Route::any("pageGetSetup", [PageController::class, 'getSetup']);
            Route::any("pageUpdateSetup", [PageController::class, 'updateSetup']);
        });

        // 主要功能
        Route::group(['prefix' => 'manage'], function () {
            // 菜单管理
            Route::any("menus", [MenusController::class, 'index']);
            Route::any("menus/insert", [MenusController::class, 'insert']);
            Route::any("menus/update", [MenusController::class, 'update']);
            Route::any("menus/remove", [MenusController::class, 'remove']);
            Route::any("menus/status", [MenusController::class, 'status']);
            Route::any("menus/rank", [MenusController::class, 'rank']);

            // 组织管理
            Route::any("group", [GroupController::class, 'index']);
            Route::any("group/insert", [GroupController::class, 'insert']);
            Route::any("group/update", [GroupController::class, 'update']);
            Route::any("group/status", [GroupController::class, 'status']);
            Route::any("group/remove", [GroupController::class, 'remove']);

            // 角色管理
            Route::any("role", [RoleController::class, 'index']);
            Route::any("role/insert", [RoleController::class, 'insert']);
            Route::any("role/update", [RoleController::class, 'update']);
            Route::any("role/status", [RoleController::class, 'status']);
            Route::any("role/remove", [RoleController::class, 'remove']);

            // 管理员管理
            Route::any("users", [UsersController::class, 'index']);
            Route::any("users/insert", [UsersController::class, 'insert']);
            Route::any("users/update", [UsersController::class, 'update']);
            Route::any("users/status", [UsersController::class, 'status']);
            Route::any("users/remove", [UsersController::class, 'remove']);

            // 后台日志管理
            Route::any("log/access", [LogController::class, 'access']);
            Route::any("log/access/clear", [LogController::class, 'accessClear']);
            Route::any("log/login", [LogController::class, 'login']);
            Route::any("log/login/clear", [LogController::class, 'loginClear']);
        });

    });

});